import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;

public class SelectNumber {
    public int selectSelfRed(int[] red,int[] a){
        int x=0;
        Scanner scanner=new Scanner(System.in);
        int[] b=new int[a.length];
        for (int i=0;i<=a.length-1;i++){
            System.out.println("请输入你要选择的红球号码：");
            String str=scanner.nextLine();
            b[i]=Integer.parseInt(str);
        }
        System.out.println("你输入的号码是：");
        sortArray(b);
        for (int i=0;i<=b.length-1;i++){
            System.out.print(b[i]+"  ");
        }
        System.out.println("  ");
        System.out.println("本轮抽奖红球的中奖号码为：");
        for (int i=0;i<=a.length-1;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println("  ");
        System.out.print("你红球中奖的号码是：");
        for (int i=0;i<=b.length-1;i++){
            for (int j=0;j<=a.length-1;j++){
                if (b[i]==a[j]){
                    System.out.print(b[i]+" ");
                    x++;
                }
            }
        }
        System.out.println("  ");
        return x;
    }
    public int selectSelfBlue(int[] blue,int n){
        System.out.println("请输入蓝球的号码：");
        int y=0;
        Scanner scanner=new Scanner(System.in);
        String str= scanner.nextLine();
        int i=Integer.parseInt(str);
        System.out.println("本轮抽奖蓝球中奖号码为："+n);
        if (y==i){
            y++;
            System.out.print("你蓝球中奖的号码是："+i);
        }
        System.out.println("  ");
        return y;
    }
    public int selectComputerRed(int[] b){
        int x=0;
        Set<Integer> set=new HashSet<>();
        Random random=new Random();
        while (true){
            int n=random.nextInt(33)+1;
            set.add(n);
            if (set.size()>=6){
                break;
            }
        }
        Object[] objs=set.toArray();
        int[] a=new int[objs.length];
        System.out.println("机选的红球号码为：");
        for (int i=0;i<=a.length-1;i++){
            a[i]=(int)objs[i];
        }
        sortArray(a);
        for (int i=0;i<=a.length-1;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println("  ");
        System.out.println("本轮抽奖红球的中奖号码为：");
        for (int i=0;i<=b.length-1;i++){
            System.out.print(b[i]+" ");
        }
        System.out.println("  ");
        System.out.print("你本轮红球中奖的号码为：");
        for (int i=0;i<=a.length-1;i++){
            for (int j=0;j<=b.length-1;j++){
                if (a[i]==b[j]){
                    System.out.print(a[i]+" ");
                    x++;
                }
            }
        }
        System.out.println("  ");
        return x;
    }
    public int selectCompoterBlue(int n){
        int y=0;
        Random random=new Random();
        int i=random.nextInt(16)+1;
        System.out.println("机选的蓝球号码为："+i);
        System.out.println("本轮抽奖蓝球的中奖号码为："+n);
        if (i==n){
            System.out.println("你的蓝球中奖号码为："+i);
            y++;
        }
        System.out.println("  ");
        return y;
    }

    public static void sortArray(int[] s){
        int temp=0;
        for (int i=0;i<=s.length-2;i++){
            for (int j=i+1;j<=s.length-1;j++){
                if (s[i]>s[j]){
                    temp=s[i];
                    s[i]=s[j];
                    s[j]=temp;
                }
            }
        }
    }

}
